package com.heima.wemedia.controller;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.media.dtos.WmMaterialDto;
import com.heima.model.media.dtos.WmNewsDto;
import com.heima.model.media.dtos.WmNewsPageReqDto;
import com.heima.model.media.dtos.WmNewsResultDTO;
import com.heima.wemedia.service.WmMaterialService;
import com.heima.wemedia.service.WmNewsService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

public class WmNewsController {


    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/api/v1/news/page")
    public ResponseResult<WmNewsResultDTO> findByPage(@RequestBody WmNewsPageReqDto dto) {
        return wmNewsService.findByPage(dto);

    }


    @GetMapping("/api/v1/news/one/{id}")
    private ResponseResult<WmNewsResultDTO> getOne(@PathVariable Integer id) {

        return ResponseResult.ok(wmNewsService.getOneWmNews(id));

    }

    @PostMapping("/api/v1/news/submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto){
        wmNewsService.submit(dto);
        return ResponseResult.ok();
    }

}
